/*
 *    This file is part of SSHTunneler.
 *
 *    Copyright 2009 Jean-Sebastien Gelinas <calestar@gmail.com>
 *
 *    SSHTunneler is free software: you can redistribute it and/or modify
 *    it under the terms of the GNU General Public License as published by
 *    the Free Software Foundation, either version 3 of the License, or
 *    (at your option) any later version.
 *
 *    SSHTunneler is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 *
 *    You should have received a copy of the GNU General Public License
 *    along with SSHTunneler.  If not, see <http://www.gnu.org/licenses/>.
 *
 */
package sshtunneler.packager.gui.frames;

import sshtunneler.packager.installergenerator.ScriptGenerator;

public class ShowScript extends MyInternalFrame {
	private static final long serialVersionUID = 4133743800268201055L;

	public ShowScript(MyInternalFrameActionDispatcherFrame dispatcher) {
		super(dispatcher);
		this.initComponents();
		dispatcher.add_config_listener(this);
		dispatcher.add_script_variable_listener(this);
		dispatcher.add_additional_files_listener(this);
		this.refresh();
	}

	private void initComponents() {

		this.jScrollPane1 = new javax.swing.JScrollPane();
		this.txt_script = new javax.swing.JTextArea();

		this.setClosable(true);
		this
				.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
		this.setIconifiable(true);
		this.setMaximizable(true);
		this.setResizable(true);
		this.setTitle("Installer script");
		this.setName("Form");
		this.setPreferredSize(new java.awt.Dimension(410, 450));

		this.jScrollPane1.setName("jScrollPane1");

		this.txt_script.setColumns(20);
		this.txt_script.setEditable(false);
		this.txt_script.setRows(5);
		this.txt_script.setName("txt_script");
		this.txt_script.setPreferredSize(new java.awt.Dimension(200, 300));
		this.jScrollPane1.setViewportView(this.txt_script);

		this.getContentPane().add(this.jScrollPane1,
				java.awt.BorderLayout.CENTER);

		this.pack();
	}

	public void refresh() {
		String script = (new ScriptGenerator()).generate_as_string();
		script = script.replace("\\n\\", "");
		this.txt_script.setText(script);
	}

	private javax.swing.JScrollPane jScrollPane1;
	private javax.swing.JTextArea txt_script;

}
